#include <memory>
#include <string>
#include <functional>

#include <logger.h>

std::unique_ptr<int, std::function<void(int *)>> Scope(const std::string &name)
{
    LOG2SO(DEBUG) << "EnterScope: " << name;
    return {new int(), [name](int *ptr) {
        LOG2SO(DEBUG) << "ExitScope: " << name;
        delete ptr;
    }};
}

int main()
{
    auto sopcea = Scope("a");
    auto a = std::make_unique<int>();
    VALUE_LOGGER(a.get());

    auto scopeb = Scope("b");
    auto b = std::move(a);
    VALUE_LOGGER(a.get());
    VALUE_LOGGER(b.get());
    scopeb = nullptr;

    const auto &c = b;
    VALUE_LOGGER(b.get());
    VALUE_LOGGER(c.get());
    VALUE_LOGGER(&b);
    VALUE_LOGGER(&c);

    a = std::unique_ptr<int>(new int);
    a.reset(new int);
    a.release();
    return 0;
}
